package com.wngz.controller;

import com.wngz.annotion.MyLimit;
import com.wngz.service.ICodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author yellow Docter
 * @date 2024-09-28
 * @desc 蜗牛创想：www.woniuxy.com
 */
@RestController
@RequestMapping("code")
public class CodeController {

    @Autowired
    private ICodeService codeService;


    @GetMapping("{phone}")
    @MyLimit(time = 3,count = 3)  // 3分钟 只能访问3次 后面进行限流
    public String getCode(@PathVariable String phone){
        String code = codeService.getCode(phone);
        return code;
    }

    @GetMapping("login")
    public String login(String phone,String code){
        String msg = codeService.login(phone,code);
        return msg;
    }

}
